package org.creativor.rayson.common;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.PipedInputStream;
import org.creativor.rayson.api.Portable;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The class <code>StreamTest</code> contains tests for the class
 * <code>{@link Stream}</code>.
 * <p>
 * Copyright Creativor Studio (c) 2011
 * 
 * @generatedBy CodePro at 11-5-7 上午3:15
 * @author Nick Zhang
 * @version $Revision: 1.0 $
 */
public class StreamTest {
	/**
	 * Launch the test.
	 * 
	 * @param args
	 *            the command line arguments
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	public static void main(String[] args) {
		new org.junit.runner.JUnitCore().run(StreamTest.class);
	}

	/**
	 * Perform pre-test initialization.
	 * 
	 * @throws Exception
	 *             if the initialization fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Before
	public void setUp() throws Exception {
		// TODO: add additional set up code here
	}

	/**
	 * Perform post-test clean-up.
	 * 
	 * @throws Exception
	 *             if the clean-up fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@After
	public void tearDown() throws Exception {
		// TODO: add additional tear down code here
	}

	/**
	 * Run the boolean isPortable(Class) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test
	public void testIsPortable_1() throws Exception {
		Class type = Object.class;

		boolean result = Stream.isPortable(type);

		// TODO: add additional test code here
		assertEquals(false, result);
	}

	/**
	 * Run the boolean isPortable(Class) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test
	public void testIsPortable_2() throws Exception {
		Class type = Object.class;

		boolean result = Stream.isPortable(type);

		// TODO: add additional test code here
		assertEquals(false, result);
	}

	/**
	 * Run the Portable read(DataInput) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test(expected = java.io.IOException.class)
	public void testRead_1() throws Exception {
		DataInput in = new DataInputStream(new PipedInputStream());

		Portable result = Stream.read(in);

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the Portable read(DataInput) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test(expected = java.io.IOException.class)
	public void testRead_2() throws Exception {
		DataInput in = new DataInputStream(new PipedInputStream());

		Portable result = Stream.read(in);

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the Object readPortable(DataInput) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test(expected = java.io.IOException.class)
	public void testReadPortable_1() throws Exception {
		DataInput in = new DataInputStream(new PipedInputStream());

		Object result = Stream.readPortable(in);

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the Object readPortable(DataInput) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test(expected = java.io.IOException.class)
	public void testReadPortable_2() throws Exception {
		DataInput in = new DataInputStream(new PipedInputStream());

		Object result = Stream.readPortable(in);

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the Object readPortable(DataInput) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test(expected = java.io.IOException.class)
	public void testReadPortable_3() throws Exception {
		DataInput in = new DataInputStream(new PipedInputStream());

		Object result = Stream.readPortable(in);

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the void write(DataOutput,Portable) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test
	public void testWrite_1() throws Exception {
		DataOutput out = new DataOutputStream(new ByteArrayOutputStream());
		Portable value = new ClientSession();

		Stream.write(out, value);

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.lang.NullPointerException
		// at java.io.DataOutputStream.writeUTF(DataOutputStream.java:330)
		// at java.io.DataOutputStream.writeUTF(DataOutputStream.java:306)
		// at
		// org.creativor.rayson.common.ClientSession.write(ClientSession.java:80)
		// at
		// org.creativor.rayson.common.PortableObject$4.write(PortableObject.java:249)
		// at
		// org.creativor.rayson.common.PortableObject$4.write(PortableObject.java:1)
		// at org.creativor.rayson.common.Stream.write(Stream.java:49)
	}

	/**
	 * Run the void write(DataOutput,Portable) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test
	public void testWrite_2() throws Exception {
		DataOutput out = new DataOutputStream(new ByteArrayOutputStream());
		Portable value = new ClientSession();

		Stream.write(out, value);

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.lang.NullPointerException
		// at java.io.DataOutputStream.writeUTF(DataOutputStream.java:330)
		// at java.io.DataOutputStream.writeUTF(DataOutputStream.java:306)
		// at
		// org.creativor.rayson.common.ClientSession.write(ClientSession.java:80)
		// at
		// org.creativor.rayson.common.PortableObject$4.write(PortableObject.java:249)
		// at
		// org.creativor.rayson.common.PortableObject$4.write(PortableObject.java:1)
		// at org.creativor.rayson.common.Stream.write(Stream.java:49)
	}

	/**
	 * Run the void writePortable(DataOutput,Object) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test(expected = java.io.IOException.class)
	public void testWritePortable_1() throws Exception {
		DataOutput out = new DataOutputStream(new ByteArrayOutputStream());
		Object value = new Object();

		Stream.writePortable(out, value);

		// TODO: add additional test code here
	}

	/**
	 * Run the void writePortable(DataOutput,Object) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test(expected = java.io.IOException.class)
	public void testWritePortable_2() throws Exception {
		DataOutput out = new DataOutputStream(new ByteArrayOutputStream());
		Object value = new Object();

		Stream.writePortable(out, value);

		// TODO: add additional test code here
	}

	/**
	 * Run the void writePortable(DataOutput,Object) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午3:15
	 */
	@Test(expected = java.io.IOException.class)
	public void testWritePortable_3() throws Exception {
		DataOutput out = new DataOutputStream(new ByteArrayOutputStream());
		Object value = new Object();

		Stream.writePortable(out, value);

		// TODO: add additional test code here
	}
}